package com.codeoss.framework.impexp;

import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

import com.codeoss.framework.context.YunContext;
import com.codeoss.framework.data.metadata.Query;
import com.codeoss.framework.data.metadata.TableData;
import com.codeoss.framework.view.component.Table;
import com.codeoss.framework.view.model.SelectItem;

@Service
public class ExportManager implements ApplicationContextAware {
	private ApplicationContext applicationContext;
	public void exportExcel(YunContext yunContext,Table table,TableData tableData,Map<String, List<SelectItem>> selectItemMap,OutputStream os)throws IOException{
		ITableComponentExport tableComponentExport=applicationContext.getBean(ExcelTableComponentExport.class);
		tableComponentExport.export(yunContext,table, tableData, selectItemMap, os);
	}

	public void exportProperties(YunContext yunContext, com.codeoss.framework.data.metadata.Table table, Query query, OutputStream os)throws IOException{
		IPropertiesExport propertiesExport=applicationContext.getBean(IPropertiesExport.class);
		propertiesExport.exportProperties(yunContext, table, query, os);
	}
	
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		// TODO Auto-generated method stub
		this.applicationContext=applicationContext;
	}
}
